<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>Text datatype | ElasticSearch 7.7 权威指南中文版</title>
	<meta name="keywords" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <meta name="description" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <!-- Give IE8 a fighting chance -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
	<link rel="stylesheet" type="text/css" href="../static/styles.css" />
	<script>
	var _link = 'text.html';
    </script>
</head>
<body>
<div class="main-container">
    <section id="content">
        <div class="content-wrapper">
            <section id="guide" lang="zh_cn">
                <div class="container">
                    <div class="row">
                        <div class="col-xs-12 col-sm-8 col-md-8 guide-section">
                            <div style="color:gray; word-break: break-all; font-size:12px;">原英文版地址: <a href="https://www.elastic.co/guide/en/elasticsearch/reference/7.7/text.html" rel="nofollow" target="_blank">https://www.elastic.co/guide/en/elasticsearch/reference/7.7/text.html</a>, 原文档版权归 www.elastic.co 所有<br/>本地英文版地址: <a href="../en/text.html" rel="nofollow" target="_blank">../en/text.html</a></div>
                        <!-- start body -->
                  <div class="page_header">
<strong>重要</strong>: 此版本不会发布额外的bug修复或文档更新。最新信息请参考 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html" rel="nofollow">当前版本文档</a>。
</div>
<div id="content">
<div class="breadcrumbs">
<span class="breadcrumb-link"><a href="index.html">Elasticsearch Guide [7.7]</a></span>
»
<span class="breadcrumb-link"><a href="mapping.html">Mapping</a></span>
»
<span class="breadcrumb-link"><a href="mapping-types.html">Field datatypes</a></span>
»
<span class="breadcrumb-node">Text datatype</span>
</div>
<div class="navheader">
<span class="prev">
<a href="sparse-vector.html">« Sparse vector datatype</a>
</span>
<span class="next">
<a href="token-count.html">Token count datatype »</a>
</span>
</div>
<div class="section">
<div class="titlepage"><div><div>
<h2 class="title">
<a id="text"></a>Text datatype<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/mapping/types/text.asciidoc">edit</a>
</h2>
</div></div></div>

<p>A field to index full-text values, such as the body of an email or the
description of a product. These fields are <code class="literal">analyzed</code>, that is they are passed through an
<a class="xref" href="analysis.html" title="Text analysis">analyzer</a> to convert the string into a list of individual terms
before being indexed. The analysis process allows Elasticsearch to search for
individual words <em>within</em>  each full text field.  Text fields are not
used for sorting and seldom used for aggregations (although the
<a class="xref" href="search-aggregations-bucket-significanttext-aggregation.html" title="Significant Text Aggregation">significant text aggregation</a>
is a notable exception).</p>
<p>If you need to index structured content such as email addresses, hostnames, status
codes, or tags, it is likely that you should rather use a <a class="xref" href="keyword.html" title="Keyword datatype"><code class="literal">keyword</code></a> field.</p>
<p>Below is an example of a mapping for a text field:</p>
<div class="pre_wrapper lang-console">
<pre class="programlisting prettyprint lang-console">PUT my_index
{
  "mappings": {
    "properties": {
      "full_name": {
        "type":  "text"
      }
    }
  }
}</pre>
</div>
<div class="console_widget" data-snippet="snippets/704.console"></div>
<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="text-multi-fields"></a>Use a field as both text and keyword<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/mapping/types/text.asciidoc">edit</a>
</h3>
</div></div></div>
<p>Sometimes it is useful to have both a full text (<code class="literal">text</code>) and a keyword
(<code class="literal">keyword</code>) version of the same field: one for full text search and the
other for aggregations and sorting. This can be achieved with
<a class="xref" href="multi-fields.html" title="fields">multi-fields</a>.</p>
</div>

<div class="section">
<div class="titlepage"><div><div>
<h3 class="title">
<a id="text-params"></a>Parameters for text fields<a class="edit_me edit_me_private" rel="nofollow" title="Editing on GitHub is available to Elastic" href="https://github.com/elastic/elasticsearch/edit/7.7/docs/reference/mapping/types/text.asciidoc">edit</a>
</h3>
</div></div></div>
<p>The following parameters are accepted by <code class="literal">text</code> fields:</p>
<div class="informaltable">
<table border="0" cellpadding="4px">
<colgroup>
<col>
<col>
</colgroup>
<tbody valign="top">
<tr>
<td valign="top">
<p>
<a class="xref" href="analyzer.html" title="analyzer"><code class="literal">analyzer</code></a>
</p>
</td>
<td valign="top">
<p>
The <a class="xref" href="analysis.html" title="Text analysis">analyzer</a> which should be used for
the <code class="literal">text</code> field, both at index-time and at
search-time (unless overridden by the  <a class="xref" href="search-analyzer.html" title="search_analyzer"><code class="literal">search_analyzer</code></a>).
Defaults to the default index analyzer, or the
<a class="xref" href="analysis-standard-analyzer.html" title="Standard Analyzer"><code class="literal">standard</code> analyzer</a>.
</p>
</td>
</tr>
<tr>
<td valign="top">
<p>
<a class="xref" href="mapping-boost.html" title="boost"><code class="literal">boost</code></a>
</p>
</td>
<td valign="top">
<p>
Mapping field-level query time boosting. Accepts a floating point number, defaults
to <code class="literal">1.0</code>.
</p>
</td>
</tr>
<tr>
<td valign="top">
<p>
<a class="xref" href="eager-global-ordinals.html" title="eager_global_ordinals"><code class="literal">eager_global_ordinals</code></a>
</p>
</td>
<td valign="top">
<p>
Should global ordinals be loaded eagerly on refresh? Accepts <code class="literal">true</code> or <code class="literal">false</code>
(default). Enabling this is a good idea on fields that are frequently used for
(significant) terms aggregations.
</p>
</td>
</tr>
<tr>
<td valign="top">
<p>
<a class="xref" href="fielddata.html" title="fielddata"><code class="literal">fielddata</code></a>
</p>
</td>
<td valign="top">
<p>
Can the field use in-memory fielddata for sorting, aggregations,
or scripting? Accepts <code class="literal">true</code> or <code class="literal">false</code> (default).
</p>
</td>
</tr>
<tr>
<td valign="top">
<p>
<a class="xref" href="fielddata.html#field-data-filtering" title="fielddata_frequency_filter"><code class="literal">fielddata_frequency_filter</code></a>
</p>
</td>
<td valign="top">
<p>
Expert settings which allow to decide which values to load in memory when <code class="literal">fielddata</code>
is enabled. By default all values are loaded.
</p>
</td>
</tr>
<tr>
<td valign="top">
<p>
<a class="xref" href="multi-fields.html" title="fields"><code class="literal">fields</code></a>
</p>
</td>
<td valign="top">
<p>
Multi-fields allow the same string value to be indexed in multiple ways for
different purposes, such as one field for search and a multi-field for
sorting and aggregations, or the same string value analyzed by different
analyzers.
</p>
</td>
</tr>
<tr>
<td valign="top">
<p>
<a class="xref" href="mapping-index.html" title="index"><code class="literal">index</code></a>
</p>
</td>
<td valign="top">
<p>
Should the field be searchable? Accepts <code class="literal">true</code> (default) or <code class="literal">false</code>.
</p>
</td>
</tr>
<tr>
<td valign="top">
<p>
<a class="xref" href="index-options.html" title="index_options"><code class="literal">index_options</code></a>
</p>
</td>
<td valign="top">
<p>
What information should be stored in the index, for search and highlighting purposes.
Defaults to <code class="literal">positions</code>.
</p>
</td>
</tr>
<tr>
<td valign="top">
<p>
<a class="xref" href="index-prefixes.html" title="index_prefixes"><code class="literal">index_prefixes</code></a>
</p>
</td>
<td valign="top">
<p>
If enabled, term prefixes of between 2 and 5 characters are indexed into a
separate field.  This allows prefix searches to run more efficiently, at
the expense of a larger index.
</p>
</td>
</tr>
<tr>
<td valign="top">
<p>
<a class="xref" href="index-phrases.html" title="index_phrases"><code class="literal">index_phrases</code></a>
</p>
</td>
<td valign="top">
<p>
If enabled, two-term word combinations (<em>shingles</em>) are indexed into a separate
field.  This allows exact phrase queries (no slop) to run more efficiently, at the expense
of a larger index.  Note that this works best when stopwords are not removed,
as phrases containing stopwords will not use the subsidiary field and will fall
back to a standard phrase query.  Accepts <code class="literal">true</code> or <code class="literal">false</code> (default).
</p>
</td>
</tr>
<tr>
<td valign="top">
<p>
<a class="xref" href="norms.html" title="norms"><code class="literal">norms</code></a>
</p>
</td>
<td valign="top">
<p>
Whether field-length should be taken into account when scoring queries.
Accepts <code class="literal">true</code> (default) or <code class="literal">false</code>.
</p>
</td>
</tr>
<tr>
<td valign="top">
<p>
<a class="xref" href="position-increment-gap.html" title="position_increment_gap"><code class="literal">position_increment_gap</code></a>
</p>
</td>
<td valign="top">
<p>
The number of fake term position which should be inserted between each
element of an array of strings. Defaults to the <code class="literal">position_increment_gap</code>
configured on the analyzer which defaults to <code class="literal">100</code>. <code class="literal">100</code> was chosen because it
prevents phrase queries with reasonably large slops (less than 100) from
matching terms across field values.
</p>
</td>
</tr>
<tr>
<td valign="top">
<p>
<a class="xref" href="mapping-store.html" title="store"><code class="literal">store</code></a>
</p>
</td>
<td valign="top">
<p>
Whether the field value should be stored and retrievable separately from
the <a class="xref" href="mapping-source-field.html" title="_source field"><code class="literal">_source</code></a> field. Accepts <code class="literal">true</code> or <code class="literal">false</code>
(default).
</p>
</td>
</tr>
<tr>
<td valign="top">
<p>
<a class="xref" href="search-analyzer.html" title="search_analyzer"><code class="literal">search_analyzer</code></a>
</p>
</td>
<td valign="top">
<p>
The <a class="xref" href="analyzer.html" title="analyzer"><code class="literal">analyzer</code></a> that should be used at search time on
the <code class="literal">text</code> field. Defaults to the <code class="literal">analyzer</code> setting.
</p>
</td>
</tr>
<tr>
<td valign="top">
<p>
<a class="xref" href="analyzer.html#search-quote-analyzer" title="search_quote_analyzer"><code class="literal">search_quote_analyzer</code></a>
</p>
</td>
<td valign="top">
<p>
The <a class="xref" href="analyzer.html" title="analyzer"><code class="literal">analyzer</code></a> that should be used at search time when a
phrase is encountered. Defaults to the <code class="literal">search_analyzer</code> setting.
</p>
</td>
</tr>
<tr>
<td valign="top">
<p>
<a class="xref" href="similarity.html" title="similarity"><code class="literal">similarity</code></a>
</p>
</td>
<td valign="top">
<p>
Which scoring algorithm or <em>similarity</em> should be used. Defaults
to <code class="literal">BM25</code>.
</p>
</td>
</tr>
<tr>
<td valign="top">
<p>
<a class="xref" href="term-vector.html" title="term_vector"><code class="literal">term_vector</code></a>
</p>
</td>
<td valign="top">
<p>
Whether term vectors should be stored for the field. Defaults to <code class="literal">no</code>.
</p>
</td>
</tr>
<tr>
<td valign="top">
<p>
<a class="xref" href="mapping-field-meta.html" title="meta"><code class="literal">meta</code></a>
</p>
</td>
<td valign="top">
<p>
Metadata about the field.
</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>

</div>
<div class="navfooter">
<span class="prev">
<a href="sparse-vector.html">« Sparse vector datatype</a>
</span>
<span class="next">
<a href="token-count.html">Token count datatype »</a>
</span>
</div>
</div>

                  <!-- end body -->
                        </div>
                        <div class="col-xs-12 col-sm-4 col-md-4" id="right_col">
                        
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </section>
</div>
<script src="../static/cn.js"></script>
</body>
</html>